<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row>
      <el-table-column align="center" label="好友ID" prop="userId" />
      <el-table-column align="center" label="用户昵称" prop="name" />
      <el-table-column align="center" label="手机号" prop="mobile" />
      <el-table-column align="center" label="注册日期">
        <template slot-scope="scope">{{ scope.row.createDate | filterTime }}</template>
      </el-table-column>
      <el-table-column align="center" label="累计阅读时长" prop="readTimeCount" />
      <el-table-column align="center" label="累计阅读数量" prop="readNumberCount" />
      <el-table-column align="center" label="累计阅读收益(DLB)" prop="readGetdlbCount" />
      <el-table-column align="center" label="钱包余额(DLB)" prop="walletCount" />
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="listQuery.currentPages" :limit.sync="listQuery.pageSize" align="center" @pagination="fetchData" />
  </div>
</template>

<script>
import { getUserFriendList } from '@/api/table'
import Pagination from '@/components/Pagination'
import { parseTime } from '@/utils/index'

export default {
  name: 'ShareList',
  components: { Pagination },
  filters: {
    filterTime(time) {
      return parseTime(time)
    }
  },
  data() {
    return {
      list: null,
      listLoading: true,
      total: 0,
      listQuery: {
        currentPages: 1,
        pageSize: 10,
        userId: this.$route.query.userId
      }
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      getUserFriendList(this.listQuery).then(response => {
        this.list = response.data.dataList
        this.total = response.data.totalElements

        setTimeout(() => {
          this.listLoading = false
        }, 300)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.name{
  color:#409EFF;
}
</style>
